{include file="../app/view/common/header.html" page="score_admin" subtitle="成绩管理"}
<div style="display: flex;">
    <div class="mdui-textfield" style="box-shadow: rgba(9, 30, 66, 0.25) 0px 4px 8px -2px, rgba(9, 30, 66, 0.08) 0px 0px 0px 1px;padding-bottom:0px;">
        <input class="mdui-textfield-input" type="text" placeholder="新建考试名称（英文+数字）" id="type_input" style="height:20px"/>
    </div> 
    <button class="mdui-btn mdui-color-theme-accent mdui-ripple" style="left: 1%;width: 10%;" onclick="createScore(type)">新建考试</button>
    <h1> </h1>
    <select class="mdui-select select-item" mdui-select id="type_select" style="margin-left: 80px;">
        <option value="default">请选择需要考试</option>
    </select>
    <button class="mdui-btn mdui-color-theme-accent mdui-ripple" style="left: 1%;width: 10%;" onclick="loadScore(type)">看这个类型</button>
    <h1> </h1>
    <button class="mdui-btn mdui-color-theme-accent mdui-ripple" style="position: relative;left: 10%;width: 10%;" onclick="saveScore(type)">保存表格</button>
</div>

<style>
    td{padding: 5px !important;}
</style>
<div class="mdui-table-fluid">
    <table class="mdui-table mdui-table-hoverable mdui-table-selectable">
      <thead>
        <tr>
          <th>#</th>
          <th onclick="sortRank(0)">姓名</th>
          <th onclick="sortRank(1)">作文</th>
          <th onclick="sortRank(2)">听力1</th>
          <th onclick="sortRank(3)">听力2</th>
          <th onclick="sortRank(4)">选词填空</th>
          <th onclick="sortRank(5)">长篇阅读</th>
          <th onclick="sortRank(6)">仔细阅读</th>
          <th onclick="sortRank(7)">翻译</th>
          <th onclick="sortRank(8)">百分制</th>
          <th onclick="sortRank(9)">总分制</th>
        </tr>
      </thead>
      <tbody id="table">
        
      </tbody>
    </table>
  </div>
<script>
    table = document.getElementById("table")
    var sub = `<tr name="REALNAME">
            <td>ID</td>
            <td>REALNAME</td>
            <td id="ID_1" ONCLICK>WRITE</td>
            <td id="ID_2" ONCLICK>LISTEN1</td>
            <td id="ID_3" ONCLICK>LISTEN2</td>
            <td id="ID_4" ONCLICK>READ1</td>
            <td id="ID_5" ONCLICK>READ2</td>
            <td id="ID_6" ONCLICK>READ3</td>
            <td id="ID_7" ONCLICK>TRANS</td>
            <td id="SUM_ID_0" style="text-align:center;">0</td>
            <td id="SUM_ID_1" style="text-align:center;">0</td>
            </tr>`
function inputText(v,uid,i) {
  s=`<div class="mdui-textfield" style="box-shadow: rgba(9, 30, 66, 0.25) 0px 4px 8px -2px, rgba(9, 30, 66, 0.08) 0px 0px 0px 1px;padding-bottom:0px;">
  <input class="mdui-textfield-input" type="number" placeholder="" value="VALUE" onkeydown="jumpNext()" id="INPUT_UID_IIIII" onblur="calcSum(UID)"/>
</div>`
  return s.replaceAll("VALUE",v).replaceAll("UID",uid).replaceAll("IIIII",i)
}
no_score_data = {
  write:"",listen1:"",listen2:"",read1:"",read2:"",read3:"",trans:""
}
score_list = ["write","listen1","listen2","read1","read2","read3","trans"]
var nowI = -1
var nowID = -1
user_to_uid = new Object()
function replaceFunc(d,i) {
  if (score_data[d.uid] === undefined) score_data[d.uid] = no_score_data
  nowI = i-1
  nowID = d.uid
  user_to_uid[i]=d.uid
  setTimeout("calcSum("+d.uid+")",10)
  return sub
  .replaceAll("ONCLICK",'onblur="calcSum(ID)"')
  .replaceAll("ID",d.uid)
  .replaceAll("REALNAME",d.realname)
  .replaceAll("WRITE",inputText(score_data[d.uid].write,d.uid,"write"))
  .replaceAll("LISTEN1",inputText(score_data[d.uid].listen1,d.uid,"listen1"))
  .replaceAll("LISTEN2",inputText(score_data[d.uid].listen2,d.uid,"listen2"))
  .replaceAll("READ1",inputText(score_data[d.uid].read1,d.uid,"read1"))
  .replaceAll("READ2",inputText(score_data[d.uid].read2,d.uid,"read2"))
  .replaceAll("READ3",inputText(score_data[d.uid].read3,d.uid,"read3"))
  .replaceAll("TRANS",inputText(score_data[d.uid].trans,d.uid,"trans"))
}
</script>

<script>type="{$type}";document.getElementById("type_input").value=type</script>
<script src="/static/score/admin.js"></script>
<script src="/static/user/list.js"></script>
